/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logicwin.RobotTravel;

/**
 *
 * @author Administrator
 */
import com.logicwin.RobotTravel.utils.SystemParams;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.TabHost;

public class IntroDialog extends TabActivity {
	private TabHost tabHost;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.intro_dialog);

		/* get the sceen info */
		String sceen = this.getIntent().getExtras().getString("sceen");
		//String sceen = "sceen1";
		Resources res = getResources(); // Resource object to get Drawables
		tabHost = getTabHost(); // The activity TabHost
		this.adjustHostSize();

		TabHost.TabSpec spec; // Reusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab
		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, IntroDialogTabText.class);
		intent.putExtra("sceen", sceen);
		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost.newTabSpec("A")
				.setIndicator("简介", res.getDrawable(R.drawable.hzlogotm))
				.setContent(intent);
		// TabSpec android.widget.TabHost.TabSpec.setContent(Intent intent)
		tabHost.addTab(spec);
		// Do the same for the other tabs
		intent = new Intent().setClass(this, IntroDialogTabPic.class);
		intent.putExtra("sceen", sceen);
		spec = tabHost.newTabSpec("B")
				.setIndicator("图片", res.getDrawable(R.drawable.hzlogotm))
				.setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, IntroDialogTabVideo.class);
		intent.putExtra("sceen", sceen);
		spec = tabHost.newTabSpec("C")
				.setIndicator("视频", res.getDrawable(R.drawable.hzlogotm))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTabByTag("A");

	}

	/* set tab host size to 3/4 window size */
	private void adjustHostSize() {
		int width = SystemParams.getWindowWidth(this) * 3 / 4;
		int height = SystemParams.getWindowHeight(this) * 3 / 4;
		FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) tabHost
				.getLayoutParams();
		params.width = width;
		params.height = height;
		tabHost.setLayoutParams(params);
	}
}
